#! /bin/sh
:
#$Id: mansed,v 1.29.4.1 2000/05/09 06:36:35 guenther Exp $

if test -z "$IFS"
then IFS=" \
	\

"
  export IFS
fi

test 5 != $# &&
 echo "Don't start this script directly, use \`make'" && exit 1

SHELL=$1
SRC="$2"
DEST="$3"
RM="$4"
DEVNULL=$5
export SHELL SRC DEST RM DEVNULL
TMPF0=/tmp/_mansed.0.$$
TMPF1=/tmp/_mansed.1.$$

if test ! -f "$DEST"
then
 trap "$RM \"$DEST\" $TMPF0 $TMPF1;exit 1" 1 2 3 15
fi

(cat <<\HERE
.\"if n .pl +(135i-\n(.pu)
.de Id
.ds Rv \\$3
.ds Dt \\$4
..
HERE
sed -e '1,/^.ex/ d' -e '/^\.TH/ q' <$SRC
cat <<\HERE
.rn SH Sh
.de SH
.br
.ne 11
.Sh "\\$1"
..
.rn SS Ss
.de SS
.br
.ne 10
.Ss "\\$1"
..
.rn TP Tp
.de TP
.br
.ne 9
.Tp \\$1
..
.rn RS Rs
.de RS
.na
.nf
.Rs
..
.rn RE Re
.de RE
.Re
.fi
.ad
..
.de Sx
.PP
.ne \\$1
.RS
..
.de Ex
.RE
.PP
..
HERE
sed -e '1,/^\.TH/ d' <$SRC
expr "X$DEST" : '.*[18]$' >$DEVNULL && cat <<HERE
.Sh SOURCE
This program is part of the
.I procmail mail-processing-package
(v@PM_VERSION@) available at http://www.procmail.org/ or
ftp.procmail.org in
.BR pub/procmail/ .
.Sh MAILINGLIST
There exists a mailinglist for questions relating to any program in the
procmail package:
.RS
@PM_MAILINGLIST@
.RS
for submitting questions/answers.
.RE
@PM_MAILINGLISTR@
.RS
for subscription requests.
.RE
.PP
.RE
If you would like to stay informed about new versions and official patches send
a subscription request to
.RS
procmail-announce-request@procmail.org
.RE
(this is a readonly list).
HERE
cat <<HERE
.SH AUTHORS
@AUTHORS@
.\".if n .pl -(\n(.tu-1i)
.rm SH
.rn Sh SH
.rm SS
.rn Ss SS
.rm TP
.rn Tp TP
.rm RS
.rn Rs RS
.rm RE
.rn Re RE
HERE
 )| sed -f man.sed.0000 >$TMPF0

if test $? != 0
then
  $RM $TMPF0
  exit 1
fi

for a in man.sed.[0-9]*
do
  case $a in
     man.sed.0000) ;;
     man.sed.????)
	mv $TMPF0 $TMPF1
	if sed -f $a <$TMPF1 >$TMPF0
	then
	:
	else
	   $RM $TMPF1 $TMPF0
	   exit 1
	fi
  esac
done

cat $TMPF0 >"$DEST"
result=$?

$RM $TMPF0 $TMPF1
exit $result
